home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / ADSP.h next >
Text File  |  1995-07-06  |  11KB  |  284 lines

  1. /*
  2.      File:        ADSP.h
  3.  
  4.      Contains:    AppleTalk Data Stream Protocol (ADSP) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __ADSP__
  21. #define __ADSP__
  22.  
  23.  
  24. #ifndef __ERRORS__
  25. #include <Errors.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __APPLETALK__
  30. #include <AppleTalk.h>
  31. #endif
  32. /*    #include <Types.h>                                            */
  33. /*    #include <OSUtils.h>                                        */
  34. /*        #include <MixedMode.h>                                    */
  35. /*        #include <Memory.h>                                        */
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_ALIGN_SUPPORTED
  42. #pragma options align=mac68k
  43. #endif
  44.  
  45. #if PRAGMA_IMPORT_SUPPORTED
  46. #pragma import on
  47. #endif
  48.  
  49.  
  50. enum {
  51.     dspInit                        = 255,                            /* create a new connection end */
  52.     dspRemove                    = 254,                            /* remove a connection end */
  53.     dspOpen                        = 253,                            /* open a connection */
  54.     dspClose                    = 252,                            /* close a connection */
  55.     dspCLInit                    = 251,                            /* create a connection listener */
  56.     dspCLRemove                    = 250,                            /* remove a connection listener */
  57.     dspCLListen                    = 249,                            /* post a listener request */
  58.     dspCLDeny                    = 248,                            /* deny an open connection request */
  59.     dspStatus                    = 247,                            /* get status of connection end */
  60.     dspRead                        = 246,                            /* read data from the connection */
  61.     dspWrite                    = 245,                            /* write data on the connection */
  62.     dspAttention                = 244                            /* send an attention message */
  63. };
  64.  
  65. enum {
  66.     dspOptions                    = 243,                            /* set connection end options */
  67.     dspReset                    = 242,                            /* forward reset the connection */
  68.     dspNewCID                    = 241,                            /* generate a cid for a connection end */
  69. /* connection opening modes */
  70.     ocRequest                    = 1,                            /* request a connection with remote */
  71.     ocPassive                    = 2,                            /* wait for a connection request from remote */
  72.     ocAccept                    = 3,                            /* accept request as delivered by listener */
  73.     ocEstablish                    = 4,                            /* consider connection to be open */
  74. /* connection end states */
  75.     sListening                    = 1,                            /* for connection listeners */
  76.     sPassive                    = 2,                            /* waiting for a connection request from remote */
  77.     sOpening                    = 3,                            /* requesting a connection with remote */
  78.     sOpen                        = 4,                            /* connection is open */
  79.     sClosing                    = 5,                            /* connection is being torn down */
  80.     sClosed                        = 6,                            /* connection end state is closed */
  81. /* client event flags */
  82.     eClosed                        = 0x80,                            /* received connection closed advice */
  83.     eTearDown                    = 0x40,                            /* connection closed due to broken connection */
  84.     eAttention                    = 0x20,                            /* received attention message */
  85.     eFwdReset                    = 0x10,                            /* received forward reset advice */
  86. /* miscellaneous constants */
  87.     attnBufSize                    = 570,                            /* size of client attention buffer */
  88.     minDSPQueueSize                = 100                            /* Minimum size of receive or send Queue */
  89. };
  90.  
  91. /* connection control block */
  92. struct TRCCB {
  93.     struct TRCCB                    *ccbLink;                    /* link to next ccb */
  94.     UInt16                            refNum;                        /* user reference number */
  95.     UInt16                            state;                        /* state of the connection end */
  96.     UInt8                            userFlags;                    /* flags for unsolicited connection events */
  97.     UInt8                            localSocket;                /* socket number of this connection end */
  98.     AddrBlock                        remoteAddress;                /* internet address of remote end */
  99.     UInt16                            attnCode;                    /* attention code received */
  100.     UInt16                            attnSize;                    /* size of received attention data */
  101.     void                            *attnPtr;                    /* ptr to received attention data */
  102.     UInt8                            reserved[220];                /* for adsp internal use */
  103. };
  104. typedef struct TRCCB TRCCB;
  105.  
  106. typedef TRCCB *TPCCB;
  107.  
  108. typedef struct DSPParamBlock DSPParamBlock, *DSPPBPtr;
  109.  
  110. /*
  111.         ADSPConnectionEventProcPtr uses register based parameters on the 68k and cannot
  112.         be written in or called from a high-level language without the help of
  113.         mixed mode or assembly glue.
  114.  
  115.             typedef pascal void (*ADSPConnectionEventProcPtr)(TPCCB sourceCCB);
  116.  
  117.         In:
  118.          => sourceCCB       A1.L
  119. */
  120. /*
  121.         ADSPCompletionProcPtr uses register based parameters on the 68k and cannot
  122.         be written in or called from a high-level language without the help of
  123.         mixed mode or assembly glue.
  124.  
  125.             typedef pascal void (*ADSPCompletionProcPtr)(DSPPBPtr thePBPtr);
  126.  
  127.         In:
  128.          => thePBPtr        A0.L
  129. */
  130.  
  131. #if GENERATINGCFM
  132. typedef UniversalProcPtr ADSPConnectionEventUPP;
  133. typedef UniversalProcPtr ADSPCompletionUPP;
  134. #else
  135. typedef Register68kProcPtr ADSPConnectionEventUPP;
  136. typedef Register68kProcPtr ADSPCompletionUPP;
  137. #endif
  138.  
  139. struct TRinitParams {
  140.     TPCCB                            ccbPtr;                        /* pointer to connection control block */
  141.     ADSPConnectionEventUPP            userRoutine;                /* client routine to call on event */
  142.     UInt16                            sendQSize;                    /* size of send queue (0..64K bytes) */
  143.     void                            *sendQueue;                    /* client passed send queue buffer */
  144.     UInt16                            recvQSize;                    /* size of receive queue (0..64K bytes) */
  145.     void                            *recvQueue;                    /* client passed receive queue buffer */
  146.     void                            *attnPtr;                    /* client passed receive attention buffer */
  147.     UInt8                            localSocket;                /* local socket number */
  148.     UInt8                            filler1;                    /* filler for proper byte alignment */
  149. };
  150. typedef struct TRinitParams TRinitParams, *TRinitParamsPtr;
  151.  
  152. struct TRopenParams {
  153.     UInt16                            localCID;                    /* local connection id */
  154.     UInt16                            remoteCID;                    /* remote connection id */
  155.     AddrBlock                        remoteAddress;                /* address of remote end */
  156.     AddrBlock                        filterAddress;                /* address filter */
  157.     UInt32                            sendSeq;                    /* local send sequence number */
  158.     UInt16                            sendWindow;                    /* send window size */
  159.     UInt32                            recvSeq;                    /* receive sequence number */
  160.     UInt32                            attnSendSeq;                /* attention send sequence number */
  161.     UInt32                            attnRecvSeq;                /* attention receive sequence number */
  162.     UInt8                            ocMode;                        /* open connection mode */
  163.     UInt8                            ocInterval;                    /* open connection request retry interval */
  164.     UInt8                            ocMaximum;                    /* open connection request retry maximum */
  165.     UInt8                            filler2;                    /* filler for proper byte alignment */
  166. };
  167. typedef struct TRopenParams TRopenParams, *TRopenParamsPtr;
  168.  
  169. struct TRcloseParams {
  170.     UInt8                            abort;                        /* abort connection immediately if non-zero */
  171.     UInt8                            filler3;                    /* filler for proper byte alignment */
  172. };
  173. typedef struct TRcloseParams TRcloseParams, *TRcloseParamsPtr;
  174.  
  175. struct TRioParams {
  176.     UInt16                            reqCount;                    /* requested number of bytes */
  177.     UInt16                            actCount;                    /* actual number of bytes */
  178.     void                            *dataPtr;                    /* pointer to data buffer */
  179.     UInt8                            eom;                        /* indicates logical end of message */
  180.     UInt8                            flush;                        /* send data now */
  181. };
  182. typedef struct TRioParams TRioParams, *TRioParamsPtr;
  183.  
  184. struct TRattnParams {
  185.     UInt16                            attnCode;                    /* client attention code */
  186.     UInt16                            attnSize;                    /* size of attention data */
  187.     void                            *attnData;                    /* pointer to attention data */
  188.     UInt8                            attnInterval;                /* retransmit timer in 10-tick intervals */
  189.     UInt8                            filler4;                    /* filler for proper byte alignment */
  190. };
  191. typedef struct TRattnParams TRattnParams, *TRattnParamsPtr;
  192.  
  193. struct TRstatusParams {
  194.     TPCCB                            statusCCB;                    /* pointer to ccb */
  195.     UInt16                            sendQPending;                /* pending bytes in send queue */
  196.     UInt16                            sendQFree;                    /* available buffer space in send queue */
  197.     UInt16                            recvQPending;                /* pending bytes in receive queue */
  198.     UInt16                            recvQFree;                    /* available buffer space in receive queue */
  199. };
  200. typedef struct TRstatusParams TRstatusParams, *TRstatusParamsPtr;
  201.  
  202. struct TRoptionParams {
  203.     UInt16                            sendBlocking;                /* quantum for data packets */
  204.     UInt8                            sendTimer;                    /* send timer in 10-tick intervals */
  205.     UInt8                            rtmtTimer;                    /* retransmit timer in 10-tick intervals */
  206.     UInt8                            badSeqMax;                    /* threshold for sending retransmit advice */
  207.     UInt8                            useCheckSum;                /* use ddp packet checksum */
  208. };
  209. typedef struct TRoptionParams TRoptionParams, *TRoptionParamsPtr;
  210.  
  211. struct TRnewcidParams {
  212.     UInt16                            newcid;                        /* new connection id returned */
  213. };
  214. typedef struct TRnewcidParams TRnewcidParams, *TRnewcidParamsPtr;
  215.  
  216. struct DSPParamBlock {
  217.     struct QElem                    *qLink;
  218.     short                            qType;
  219.     short                            ioTrap;
  220.     Ptr                                ioCmdAddr;
  221.     ADSPCompletionUPP                ioCompletion;
  222.     OSErr                            ioResult;
  223.     StringPtr                        ioNamePtr;
  224.     short                            ioVRefNum;
  225.     short                            ioCRefNum;                    /* adsp driver refNum */
  226.     short                            csCode;                        /* adsp driver control code */
  227.     long                            qStatus;                    /* adsp internal use */
  228.     short                            ccbRefNum;
  229.     union {
  230.         TRinitParams                    initParams;                /*dspInit, dspCLInit*/
  231.         TRopenParams                    openParams;                /*dspOpen, dspCLListen, dspCLDeny*/
  232.         TRcloseParams                    closeParams;            /*dspClose, dspRemove*/
  233.         TRioParams                        ioParams;                /*dspRead, dspWrite*/
  234.         TRattnParams                    attnParams;                /*dspAttention*/
  235.         TRstatusParams                    statusParams;            /*dspStatus*/
  236.         TRoptionParams                    optionParams;            /*dspOptions*/
  237.         TRnewcidParams                    newCIDParams;            /*dspNewCID*/
  238.     } u;
  239. };
  240.  
  241. enum {
  242.     uppADSPConnectionEventProcInfo = kRegisterBased
  243.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA1, SIZE_CODE(sizeof(TPCCB))),
  244.     uppADSPCompletionProcInfo = kRegisterBased
  245.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(DSPPBPtr)))
  246. };
  247.  
  248. #if GENERATINGCFM
  249. #define NewADSPConnectionEventProc(userRoutine)        \
  250.         (ADSPConnectionEventUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, GetCurrentArchitecture())
  251. #define NewADSPCompletionProc(userRoutine)        \
  252.         (ADSPCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPCompletionProcInfo, GetCurrentArchitecture())
  253. #else
  254. #define NewADSPConnectionEventProc(userRoutine)        \
  255.         ((ADSPConnectionEventUPP) (userRoutine))
  256. #define NewADSPCompletionProc(userRoutine)        \
  257.         ((ADSPCompletionUPP) (userRoutine))
  258. #endif
  259.  
  260. #if GENERATINGCFM
  261. #define CallADSPConnectionEventProc(userRoutine, sourceCCB)        \
  262.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, (sourceCCB))
  263. #define CallADSPCompletionProc(userRoutine, thePBPtr)        \
  264.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppADSPCompletionProcInfo, (thePBPtr))
  265. #else
  266. /* (*ADSPConnectionEventProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  267. /* (*ADSPCompletionProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  268. #endif
  269.  
  270.  
  271. #if PRAGMA_IMPORT_SUPPORTED
  272. #pragma import off
  273. #endif
  274.  
  275. #if PRAGMA_ALIGN_SUPPORTED
  276. #pragma options align=reset
  277. #endif
  278.  
  279. #ifdef __cplusplus
  280. }
  281. #endif
  282.  
  283. #endif /* __ADSP__ */
  284.